Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate visitors automatically #698

Merged
merged 8 commits into from
Jul 10, 2024
Merged

Generate visitors automatically #698

merged 8 commits into from
Jul 10, 2024

Conversation

W95Psp
Copy link
Collaborator

@W95Psp W95Psp commented Jun 3, 2024

This PR:

  • drops the manually implemented visitors, which are hard to maintain and error-prone;
  • adds a OCaml utility binary generate_visitors that derive those visitors reading the ast.ml module;
  • adds a dune rule to generate the module ast_visitors using generate_visitors

Note: the CI is failing for Charon, but that's likely because of rustc updates

@franziskuskiefer franziskuskiefer added the waiting-on-author Status: This is awaiting some action from the author. label Jun 21, 2024
@W95Psp W95Psp force-pushed the generate-visitors branch 2 times, most recently from bb9ce9b to 99d4614 Compare June 24, 2024 08:17
@W95Psp W95Psp added waiting-on-reviewer Status: Awaiting review from the assignee but also interested parties. and removed waiting-on-author Status: This is awaiting some action from the author. labels Jun 24, 2024
Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this PR.

You generate the visitor code but then also commit it? What is the intended workflow here?

engine/utils/generate_visitors/README.md Show resolved Hide resolved
@W95Psp
Copy link
Collaborator Author

W95Psp commented Jun 26, 2024

No, I commit small visitors for the types used by the visitor generator 😅 so yes, that's particularly confusing.
The visitor generator is designed for the types in the module Ast, it doesn't solve the general problem of generating visitors, which is more complicated. But we don't need a general solution, whence that small OCaml utility.

That utility defines a small AST for representing types, and I needed visitors for that small AST, which I generated using the tool itself, but since it's that AST is a bit different, I had to do manual edits. That's why I commit that visitors.ml file.
The visitors of the engine itself are now gone and fully generated.

Copy link
Member

@franziskuskiefer franziskuskiefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comments to all the new code before merging.

@W95Psp W95Psp enabled auto-merge July 9, 2024 12:43
@W95Psp W95Psp added this pull request to the merge queue Jul 10, 2024
Merged via the queue into main with commit b462111 Jul 10, 2024
13 checks passed
@W95Psp W95Psp deleted the generate-visitors branch July 10, 2024 04:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
waiting-on-reviewer Status: Awaiting review from the assignee but also interested parties.
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants